body{
    height: 1000px;
}

div{
    width: 40px;
    height: 40px;
    background: hotpink;
    text-align: center;
    line-height: 40px;
    border: red 1px solid;
}

div:nth-of-type(1){
    /*绝对定位：按照浏览器定位*/
    position: absolute;
    top: 400px;
    right: 0;
}

div:nth-of-type(2){
    /*固定定位*/
    position: fixed;
    background: #5cbbd5;
    right: 0;
    top: 600px;
}